import http from '@/util/http'
import qs from 'qs'

export function delUser (id) {
  return http.delete(`/users?id=${id}`)
}

export function repeatUser (params) {
  return http.get(`/user/repeat?${params}`)
}

export function userList (search, current, pageSize) {
  return http.post(`/user/get?pageNo=${current}&pageSize=${pageSize}`, search)
}

export function addUserRole (userId, roles) {
  return http.post('/user/userRole', qs.stringify({ userId: userId, roles: roles }, { arrayFormat: 'repeat' }))
}

export function addUser (data) {
  return http.post('/users', data)
}

export function updateUser (data) {
  return http.put('/users', data)
}

export function userStatus (data) {
  return http.post('/user/status', data)
}
